﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

public partial class UserRegister : System.Web.UI.Page
{
    private Operation op = new Operation();
    private User user = new User();
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (RegtxtPassWords.Text.Length != 0 && RegtxtUserName.Text.Length != 0)
        {
            user.Pwd = RegtxtPassWords.Text;
            user.Uid = RegtxtUserName.Text;
            user.Roleid = ddlRole.SelectedItem.Value;
            if (op.UserRegist(user))
            {
                Response.Write("<script language='javascript'>alert('注册成功！');window.location.href='\\UserLogin.aspx'</script>");
                
            }
            else
            {
                Response.Write("<script language='javascript'>alert('用户名已存在，请重试！');</script>");
            }
        }
        else
        {
            Response.Write("<script language='javascript'>alert('用户名密码不能为空！');</script>");
            return;
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect(@"~\UserLogin.aspx");
    }
}